import 'package:fluro/fluro.dart';
import 'package:flutter/cupertino.dart';
import 'package:xview/example/button.dart';
import 'package:xview/example/dropdown.dart';
import 'package:xview/example/home.dart';
import 'package:xview/example/loadMore.dart';
import 'package:xview/example/navbar.dart';
import 'package:xview/example/swiper.dart';
import 'package:xview/example/tabs.dart';
import 'package:xview/example/tabsSwiper.dart';

class MyRouter{
  static final router = FluroRouter();

  static final routes = {
    '/home':Handler(
      handlerFunc: (ctx,params) => home()
    ),
    '/dropdown':Handler(
      handlerFunc: (ctx,params) => dropdown()
    ),
    '/navbar':Handler(
      handlerFunc: (ctx,params) => navbar()
    ),
    '/button':Handler(
      handlerFunc: (ctx,params) => button()
    ),
    '/dropDown':Handler(
      handlerFunc: (ctx,params) => dropdown()
    ),
    '/swiper':Handler(
      handlerFunc: (ctx,params) => swiper()
    ),
    '/tabs':Handler(
      handlerFunc: (ctx,params) => tabs()
    ),
    '/tabsSwiper':Handler(
      handlerFunc: (ctx,params) => tabsSwiper()
    ),
    '/loadMore':Handler(
      handlerFunc: (ctx,params) => loadMore()
    )
  };

  static void init(){
    routes.forEach((key, value) {
      router.define(key,handler: value);
    });
  }

  static void go(BuildContext context,path,[arguments]){
    router.navigateTo(context, path ,routeSettings: RouteSettings(
      arguments:arguments,
    ),transition: TransitionType.cupertino);
  }

  static void back(BuildContext context){
    router.pop(context);
  }

}